﻿@model ProductModel

@using SDF.Core.Domain.Catalog;
@using SDF.Services.Catalog;
@using System.Text;
@using SDF.Services
@using SDF.Services.Customers
@using SDF.Services.Projects

@{
    //resources for product tags input
    Html.AppendCssFileParts("~/Administration/Content/tagEditor/jquery.tag-editor.css");
    Html.AppendScriptParts("~/Administration/Scripts/tagEditor/jquery.tag-editor.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/tagEditor/jquery.caret.min.js");
}

<script type="text/javascript">
    $(document).ready(function() {
        @if (!Model.IsLoggedInAsVendor)
        {
            <text>$("#@Html.FieldIdFor(model => model.ShowOnHomePage)").click(toggleShowOnHomePage);</text>
        }
        $("#@Html.FieldIdFor(model => model.ProductTypeId)").change(toggleProductType);
        $("#@Html.FieldIdFor(model => model.RequireOtherProducts)").click(toggleRequireOtherProducts);
        $("#@Html.FieldIdFor(model => model.AvailableForPreOrder)").click(togglePreOrder);
        $("#@Html.FieldIdFor(model => model.IsGiftCard)").click(toggleGiftCard);
        $("#@Html.FieldIdFor(model => model.CustomerEntersPrice)").click(toggleCustomerEntersPrice);
        $("#@Html.FieldIdFor(model => model.BasepriceEnabled)").click(toggleBasepriceEnabled);
        $("#@Html.FieldIdFor(model => model.IsDownload)").click(toggleDownloadableProduct);
        $("#@Html.FieldIdFor(model => model.UnlimitedDownloads)").click(toggleDownloadableProduct);
        $("#@Html.FieldIdFor(model => model.HasSampleDownload)").click(toggleDownloadableProduct);
        $("#@Html.FieldIdFor(model => model.HasUserAgreement)").click(toggleDownloadableProduct);
        $("#@Html.FieldIdFor(model => model.IsRecurring)").click(toggleRecurring);
        $("#@Html.FieldIdFor(model => model.IsRental)").click(toggleRental);
        $("#@Html.FieldIdFor(model => model.IsShipEnabled)").click(toggleShipping);
        $("#@Html.FieldIdFor(model => model.IsTaxExempt)").click(toggleTax);
        $("#@Html.FieldIdFor(model => model.ManageInventoryMethodId)").change(toggleManageStock);
        $("#@Html.FieldIdFor(model => model.UseMultipleWarehouses)").click(toggleManageStock);
        $("#@Html.FieldIdFor(model => model.BackorderModeId)").change(toggleManageStock);
        $("#@Html.FieldIdFor(model => model.DisplayStockAvailability)").click(toggleManageStock);
        $("#@Html.FieldIdFor(model => model.MarkAsNew)").click(toggleMarkAsNew);

        @if (!Model.IsLoggedInAsVendor)
        {
            <text>toggleShowOnHomePage();</text>
        }
        toggleProductType();
        togglePreOrder();
        toggleRequireOtherProducts();
        toggleGiftCard();
        toggleCustomerEntersPrice();
        toggleBasepriceEnabled();
        toggleDownloadableProduct();
        toggleRecurring();
        toggleRental();
        toggleShipping();
        toggleTax();
        toggleManageStock();
        toggleMarkAsNew();
    });

    function toggleShowOnHomePage() {
        if ($('#@Html.FieldIdFor(model => model.ShowOnHomePage)').is(':checked')) {
            $('#pnlDisplayOrder').show();
        } else {
            $('#pnlDisplayOrder').hide();
        }
    }

    function toggleProductType() {
        var selectedProductTypeId = $("#@Html.FieldIdFor(model => model.ProductTypeId)").val();
        if (!selectedProductTypeId || selectedProductTypeId == @(((int) ProductType.SimpleProduct).ToString())) {
            $('#group-prices').show();
        $('#tier-prices').show();
        $('#group-required-other-products').show();
        $('#group-giftcard').show();
        $('#group-downloads').show();
        $('#group-recurring').show();
        $('#group-rental').show();
        $('#group-shipping').show();
        $('#group-inventory').show();
        $('#group-associated-products').hide();
    } else if (selectedProductTypeId == @(((int) ProductType.GroupedProduct).ToString())) {
        $('#group-prices').hide();
        $('#tier-prices').hide();
        $('#group-required-other-products').hide();
        $('#group-giftcard').hide();
        $('#group-downloads').hide();
        $('#group-recurring').hide();
        $('#group-rental').hide();
        $('#group-shipping').hide();
        $('#group-inventory').hide();
        $('#group-associated-products').show();
    }
    }

    function togglePreOrder() {
        if ($('#@Html.FieldIdFor(model => model.AvailableForPreOrder)').is(':checked')) {
            $('#pnlPreOrderAvailabilityStartDateTimeUtc').show();
        } else {
            $('#pnlPreOrderAvailabilityStartDateTimeUtc').hide();
        }
    }

    function toggleRequireOtherProducts() {
        if ($('#@Html.FieldIdFor(model => model.RequireOtherProducts)').is(':checked')) {
            $('#pnlRequiredProductIds').show();
            $('#pnlAutomaticallyAddRequiredProducts').show();
        } else {
            $('#pnlRequiredProductIds').hide();
            $('#pnlAutomaticallyAddRequiredProducts').hide();
        }
    }

    function toggleGiftCard() {
        if ($('#@Html.FieldIdFor(model => model.IsGiftCard)').is(':checked')) {
            $('#pnlGiftCardType').show();
            $('#pnlOverriddenGiftCardAmount').show();
        } else {
            $('#pnlGiftCardType').hide();
            $('#pnlOverriddenGiftCardAmount').hide();
        }
    }

    function toggleCustomerEntersPrice() {
        if ($('#@Html.FieldIdFor(model => model.CustomerEntersPrice)').is(':checked')) {
            $('#pnlMinimumCustomerEnteredPrice').show();
            $('#pnlMaximumCustomerEnteredPrice').show();
        } else {
            $('#pnlMinimumCustomerEnteredPrice').hide();
            $('#pnlMaximumCustomerEnteredPrice').hide();
        }
    }

    function toggleBasepriceEnabled() {
        if ($('#@Html.FieldIdFor(model => model.BasepriceEnabled)').is(':checked')) {
            $('#pnlBasepriceAmount').show();
            $('#pnlBasepriceUnit').show();
            $('#pnlBasepriceBaseAmount').show();
            $('#pnlBasepriceBaseUnit').show();
        } else {
            $('#pnlBasepriceAmount').hide();
            $('#pnlBasepriceUnit').hide();
            $('#pnlBasepriceBaseAmount').hide();
            $('#pnlBasepriceBaseUnit').hide();
        }
    }

    function toggleDownloadableProduct() {
        if ($('#@Html.FieldIdFor(model => model.IsDownload)').is(':checked')) {
            $('#pnlDownloadFile').show();
            $('#pnlUnlimitedDownloads').show();
            if ($('#@Html.FieldIdFor(model => model.UnlimitedDownloads)').is(':checked')) {
                $('#pnlMaxNumberOfDownloads').hide();
            } else {
                $('#pnlMaxNumberOfDownloads').show();
            }
            $('#pnlDownloadExpirationDays').show();
            $('#pnlDownloadActivationType').show();

            $('#pnlHasUserAgreement').show();
            if ($('#@Html.FieldIdFor(model => model.HasUserAgreement)').is(':checked')) {
                $('#pnlUserAgreementText').show();
            } else {
                $('#pnlUserAgreementText').hide();
            }

            $('#pnlHasSampleDownload').show();

            if ($('#@Html.FieldIdFor(model => model.HasSampleDownload)').is(':checked')) {
                $('#pnlSampleDownloadFile').show();
            } else {
                $('#pnlSampleDownloadFile').hide();
            }
        } else {
            $('#pnlDownloadFile').hide();
            $('#pnlUnlimitedDownloads').hide();
            $('#pnlMaxNumberOfDownloads').hide();
            $('#pnlDownloadExpirationDays').hide();
            $('#pnlDownloadActivationType').hide();
            $('#pnlHasUserAgreement').hide();
            $('#pnlUserAgreementText').hide();
            $('#pnlHasSampleDownload').hide();
            $('#pnlSampleDownloadFile').hide();
        }
    }

    function toggleShipping() {
        if ($('#@Html.FieldIdFor(model => model.IsShipEnabled)').is(':checked')) {
            $('#pnlFreeShipping').show();
            $('#pnlShipSeparately').show();
            $('#pnlAdditionalShippingCharge').show();
            $('#pnlWeight').show();
            $('#pnlLength').show();
            $('#pnlWidth').show();
            $('#pnlHeight').show();
            $('#pnlDeliveryDate').show();
        } else {
            $('#pnlFreeShipping').hide();
            $('#pnlShipSeparately').hide();
            $('#pnlAdditionalShippingCharge').hide();
            $('#pnlWeight').hide();
            $('#pnlLength').hide();
            $('#pnlWidth').hide();
            $('#pnlHeight').hide();
            $('#pnlDeliveryDate').hide();
        }
    }

    function toggleRecurring() {
        if ($('#@Html.FieldIdFor(model => model.IsRecurring)').is(':checked')) {
            $('#pnlCycleLength').show();
            $('#pnlCyclePeriod').show();
            $('#pnlTotalCycles').show();
        } else {
            $('#pnlCycleLength').hide();
            $('#pnlCyclePeriod').hide();
            $('#pnlTotalCycles').hide();
        }
    }

    function toggleRental() {
        if ($('#@Html.FieldIdFor(model => model.IsRental)').is(':checked')) {
            $('#pnlRentalPriceLength').show();
            $('#pnlRentalPricePeriod').show();
        } else {
            $('#pnlRentalPriceLength').hide();
            $('#pnlRentalPricePeriod').hide();
        }
    }

    function toggleTax() {
        if ($('#@Html.FieldIdFor(model => model.IsTaxExempt)').is(':checked')) {
            $('#pnlTaxCategory').hide();
        } else {
            $('#pnlTaxCategory').show();
        }
    }

    function toggleManageStock() {
        var selectedManageInventoryMethodId = $("#@Html.FieldIdFor(model => model.ManageInventoryMethodId)").val();
        if (selectedManageInventoryMethodId == @(((int) ManageInventoryMethod.DontManageStock).ToString())) {
            $('#pnlUseMultipleWarehouses').hide();
        $('#pnlWarehouse').show();
        $('#pnlMultipleWarehouses').hide();
        $('#pnlStockQuantity').hide();
        $('#pnlDisplayStockAvailability').hide();
        $('#pnlDisplayStockQuantity').hide();
        $('#pnlMinStockQuantity').hide();
        $('#pnlLowStockActivity').hide();
        $('#pnlNotifyForQuantityBelow').hide();
        $('#pnlAllowBackInStockSubscriptions').hide();
        $('#pnlBackorders').hide();
        $('#pnlAllowAddingOnlyExistingAttributeCombinations').hide();
    } else if (selectedManageInventoryMethodId == @(((int) ManageInventoryMethod.ManageStock).ToString())) {
        $('#pnlUseMultipleWarehouses').show();

        if ($('#@Html.FieldIdFor(model => model.UseMultipleWarehouses)').is(':checked')) {
            $('#pnlWarehouse').hide();
            $('#pnlMultipleWarehouses').show();
            $('#pnlStockQuantity').hide();
        } else {
            $('#pnlWarehouse').show();
            $('#pnlMultipleWarehouses').hide();
            $('#pnlStockQuantity').show();
        }

        $('#pnlDisplayStockAvailability').show();
        if ($('#@Html.FieldIdFor(model => model.DisplayStockAvailability)').is(':checked')) {
            $('#pnlDisplayStockQuantity').show();
        } else {
            $('#pnlDisplayStockQuantity').hide();
        }

        $('#pnlMinStockQuantity').show();
        $('#pnlLowStockActivity').show();
        $('#pnlNotifyForQuantityBelow').show();
        $('#pnlBackorders').show();
        var selectedBackorderModeId = $("#@Html.FieldIdFor(model => model.BackorderModeId)").val();
        if (selectedBackorderModeId == @(((int) BackorderMode.NoBackorders).ToString())) {
            //no backorders
            $('#pnlAllowBackInStockSubscriptions').show();
    } else {
    //backorders are enabled
                $('#pnlAllowBackInStockSubscriptions').hide();
    }
    $('#pnlAllowAddingOnlyExistingAttributeCombinations').hide();
    } else {
        $('#pnlUseMultipleWarehouses').hide();
        $('#pnlWarehouse').show();
        $('#pnlMultipleWarehouses').hide();
        $('#pnlStockQuantity').hide();
        $('#pnlDisplayStockAvailability').show();
        if ($('#@Html.FieldIdFor(model => model.DisplayStockAvailability)').is(':checked')) {
            $('#pnlDisplayStockQuantity').show();
        } else {
            $('#pnlDisplayStockQuantity').hide();
        }
        $('#pnlMinStockQuantity').hide();
        $('#pnlLowStockActivity').hide();
        $('#pnlNotifyForQuantityBelow').hide();
        $('#pnlAllowBackInStockSubscriptions').hide();
        $('#pnlBackorders').hide();
        $('#pnlAllowAddingOnlyExistingAttributeCombinations').show();
    }
    }

    function toggleMarkAsNew() {
        if ($('#@Html.FieldIdFor(model => model.MarkAsNew)').is(':checked')) {
            $('#pnlMarkAsNewStartDateTimeUtc').show();
            $('#pnlMarkAsNewEndDateTimeUtc').show();
        } else {
            $('#pnlMarkAsNewStartDateTimeUtc').hide();
            $('#pnlMarkAsNewEndDateTimeUtc').hide();
        }
    }

    @{
        //TODO move to Model
        var productTags = EngineContext.Current.Resolve<IProductTagService>().GetAllProductTags();
        var productTagsSb = new StringBuilder();
        productTagsSb.Append("var initialProductTags = [");
        for (int i = 0; i < productTags.Count; i++)
        {
            var tag = productTags[i];
            productTagsSb.Append("'");
            productTagsSb.Append(HttpUtility.JavaScriptStringEncode(tag.Name));
            productTagsSb.Append("'");
            if (i != productTags.Count - 1)
            {
                productTagsSb.Append(",");
            }
        }
        productTagsSb.Append("]");
    }

    //tags
    $(document).ready(function() {
        @Html.Raw(productTagsSb.ToString())
        $("#@Html.FieldIdFor(model => model.ProductTags)").tagEditor({
            autocomplete: {
                delay: 0,
                position: { collision: 'flip' },
                source: initialProductTags
            },
            delimiter: ',',
            placeholder: 'Enter tags ...'
        });
    });

    //required product friendly names
    $(document).ready(function() {
        loadRequiredProductFriendlyNames();
    });

    $(document).ready(function() {
        $('#@Html.FieldIdFor(model => model.RequiredProductIds)')
            .data('timeout', null)
            .keyup(function() {
                clearTimeout($(this).data('timeout'));
                //one second timeout
                $(this).data('timeout', setTimeout(loadRequiredProductFriendlyNames, 1000));
            });
    });

    function loadRequiredProductFriendlyNames() {
        var inputValue = $('#@Html.FieldIdFor(model => model.RequiredProductIds)').val();
        if (inputValue) {
            //load friendly names
            $('#required-products-check-progress').show();

            var postData = {
                productIds: inputValue
            };
            addAntiForgeryToken(postData);

            $.ajax({
                cache: false,
                type: 'POST',
                url: '@Url.Action("LoadProductFriendlyNames", "Product")',
                data: postData,
                dataType: 'json',
                success: function(data) {
                    $('#required-products-check-progress').hide();
                    $('#required-product-names').text(data.Text);
                },
                failure: function() {
                    $('#required-products-check-progress').hide();
                    $('#required-product-names').text('');
                }
            });
        } else {
            $('#required-product-names').text('');
        }
    }
</script>

<div class="raw clearfix">
    <div class="@(Model.ProductEditorSettingsModel.OneColumnProductPage ? "col-md-12" : "col-md-7")">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.CommonInfo")
                </div>
                <div class="panel-body">
                    @if (Model.Id > 0)
                    {
                        <div class="form-group @(Model.ProductEditorSettingsModel.Id ? null : "advanced-setting")">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Id)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFDisplayFor(model => model.Id)
                                @Html.ValidationMessageFor(model => model.Id)
                            </div>
                        </div>
                    }
                    <div class="form-group @(Model.ProductEditorSettingsModel.ProductType ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ProductTypeId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.ProductTypeId, ((ProductType)Model.ProductTypeId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.ProductTypeId)
                        </div>
                    </div>
                    @if (Model.Id > 0 && Model.AssociatedToProductId > 0)
                    {
                        <div class="form-group @(Model.ProductEditorSettingsModel.ProductType ? null : "advanced-setting")">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.AssociatedToProductId)
                            </div>
                            <div class="col-md-9">
                                @Html.ActionLink(Model.AssociatedToProductName, "Edit", "Product", new
                           {
                               id = Model.AssociatedToProductId
                           }, new { })
                            </div>
                        </div>
                    }
                    <div class="form-group @(Model.ProductEditorSettingsModel.ProductTemplate ? null : "advanced-setting")" @(Model.AvailableProductTemplates.SelectionIsNotPossible() ? Html.Raw("style=\"display:none\"") : null)>
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ProductTemplateId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.ProductTemplateId, Model.AvailableProductTemplates)
                            @Html.ValidationMessageFor(model => model.ProductTemplateId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.VisibleIndividually ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.VisibleIndividually)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.VisibleIndividually)
                            @Html.ValidationMessageFor(model => model.VisibleIndividually)
                        </div>
                    </div>

                    @(Html.LocalizedEditor<ProductModel, ProductLocalizedModel>("product-info-localized",
                    @<div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Locales[item].Name)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.Locales[item].Name)
                                @Html.ValidationMessageFor(model => model.Locales[item].Name)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Locales[item].ShortDescription)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFTextAreaFor(model => model.Locales[item].ShortDescription)
                                @Html.ValidationMessageFor(model => model.Locales[item].ShortDescription)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Locales[item].FullDescription)
                            </div>
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Locales[item].FullDescription, "RichEditor")
                                @Html.ValidationMessageFor(model => model.Locales[item].FullDescription)
                            </div>
                        </div>
                        @Html.HiddenFor(model => model.Locales[item].LanguageId)
                    </div>
                            ,@<div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.Name)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.Name)
                                @Html.ValidationMessageFor(model => model.Name)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.ShortDescription)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFTextAreaFor(x => x.ShortDescription)
                                @Html.ValidationMessageFor(model => model.ShortDescription)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.FullDescription)
                            </div>
                            <div class="col-md-9">
                                @Html.EditorFor(x => x.FullDescription, "RichEditor")
                                @Html.ValidationMessageFor(model => model.FullDescription)
                            </div>
                        </div>
                    </div>
                            ))
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Sku)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Sku)
                            @Html.ValidationMessageFor(model => model.Sku)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Published ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Published)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Published)
                            @Html.ValidationMessageFor(model => model.Published)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.ProductTags ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ProductTags)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.ProductTags)
                            @Html.ValidationMessageFor(model => model.ProductTags)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.GTIN ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Gtin)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Gtin)
                            @Html.ValidationMessageFor(model => model.Gtin)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.ManufacturerPartNumber ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ManufacturerPartNumber)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.ManufacturerPartNumber)
                            @Html.ValidationMessageFor(model => model.ManufacturerPartNumber)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.ShowOnHomePage ? null : "advanced-setting")" @(Model.IsLoggedInAsVendor ? Html.Raw("style='display: none;'") : null)>
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ShowOnHomePage)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.ShowOnHomePage)
                            @Html.ValidationMessageFor(model => model.ShowOnHomePage)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DisplayOrder ? null : "advanced-setting")" id="pnlDisplayOrder" @(Model.IsLoggedInAsVendor ? Html.Raw("style='display: none;'") : null)>
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DisplayOrder)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.DisplayOrder)
                            @Html.ValidationMessageFor(model => model.DisplayOrder)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AllowCustomerReviews ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AllowCustomerReviews)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.AllowCustomerReviews)
                            @Html.ValidationMessageFor(model => model.AllowCustomerReviews)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AvailableStartDate ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AvailableStartDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.AvailableStartDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.AvailableStartDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AvailableEndDate ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AvailableEndDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.AvailableEndDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.AvailableEndDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MarkAsNew ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MarkAsNew)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MarkAsNew)
                            @Html.ValidationMessageFor(model => model.MarkAsNew)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MarkAsNewStartDate ? null : "advanced-setting")" id="pnlMarkAsNewStartDateTimeUtc">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MarkAsNewStartDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MarkAsNewStartDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.MarkAsNewStartDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MarkAsNewEndDate ? null : "advanced-setting")" id="pnlMarkAsNewEndDateTimeUtc">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MarkAsNewEndDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MarkAsNewEndDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.MarkAsNewEndDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AdminComment ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AdminComment)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFTextAreaFor(model => model.AdminComment)
                            @Html.ValidationMessageFor(model => model.AdminComment)
                        </div>
                    </div>
                    @if (Model.CreatedOn.HasValue)
                    {
                        <div class="form-group @(Model.ProductEditorSettingsModel.CreatedOn ? null : "advanced-setting")">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.CreatedOn)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFDisplay(Model.CreatedOn.Value.ToString("F"))
                            </div>
                        </div>
                    }
                    @if (Model.UpdatedOn.HasValue)
                    {
                        <div class="form-group @(Model.ProductEditorSettingsModel.UpdatedOn ? null : "advanced-setting")">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.UpdatedOn)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFDisplay(Model.UpdatedOn.Value.ToString("F"))
                            </div>
                        </div>
                    }
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.IsGiftCard ? null : "advanced-setting")" id="group-giftcard">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.GiftCard")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsGiftCard)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsGiftCard)
                            @Html.ValidationMessageFor(model => model.IsGiftCard)
                        </div>
                    </div>
                    <div class="form-group" id="pnlGiftCardType">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.GiftCardTypeId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.GiftCardTypeId, ((GiftCardType)Model.GiftCardTypeId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.GiftCardTypeId)
                        </div>
                    </div>
                    <div class="form-group" id="pnlOverriddenGiftCardAmount">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OverriddenGiftCardAmount)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.OverriddenGiftCardAmount)
                            @Html.ValidationMessageFor(model => model.OverriddenGiftCardAmount)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.DownloadableProduct ? null : "advanced-setting")" id="group-downloads">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.DownloadableProduct")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsDownload)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsDownload)
                            @Html.ValidationMessageFor(model => model.IsDownload)
                        </div>
                    </div>
                    <div class="form-group" id="pnlDownloadFile">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DownloadId)
                        </div>
                        <div class="col-md-5">
                            @Html.SDFEditorFor(model => model.DownloadId)
                            @Html.ValidationMessageFor(model => model.DownloadId)
                        </div>
                    </div>
                    <div class="form-group" id="pnlUnlimitedDownloads">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.UnlimitedDownloads)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.UnlimitedDownloads)
                            @Html.ValidationMessageFor(model => model.UnlimitedDownloads)
                        </div>
                    </div>
                    <div class="form-group" id="pnlMaxNumberOfDownloads">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MaxNumberOfDownloads)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MaxNumberOfDownloads)
                            @Html.ValidationMessageFor(model => model.MaxNumberOfDownloads)
                        </div>
                    </div>
                    <div class="form-group" id="pnlDownloadExpirationDays">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DownloadExpirationDays)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.DownloadExpirationDays)
                            @Html.ValidationMessageFor(model => model.DownloadExpirationDays)
                        </div>
                    </div>
                    <div class="form-group" id="pnlDownloadActivationType">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DownloadActivationTypeId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.DownloadActivationTypeId, ((DownloadActivationType)Model.DownloadActivationTypeId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.DownloadActivationTypeId)
                        </div>
                    </div>
                    <div class="form-group" id="pnlHasUserAgreement">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.HasUserAgreement)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.HasUserAgreement)
                            @Html.ValidationMessageFor(model => model.HasUserAgreement)
                        </div>
                    </div>
                    <div class="form-group" id="pnlUserAgreementText">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.UserAgreementText)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFTextAreaFor(model => model.UserAgreementText)
                            @Html.ValidationMessageFor(model => model.UserAgreementText)
                        </div>
                    </div>
                    <div class="form-group" id="pnlHasSampleDownload">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.HasSampleDownload)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.HasSampleDownload)
                            @Html.ValidationMessageFor(model => model.HasSampleDownload)
                        </div>
                    </div>
                    <div class="form-group" id="pnlSampleDownloadFile">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SampleDownloadId)
                        </div>
                        <div class="col-md-5">
                            @Html.SDFEditorFor(model => model.SampleDownloadId)
                            @Html.ValidationMessageFor(model => model.SampleDownloadId)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.RecurringProduct ? null : "advanced-setting")" id="group-recurring">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.RecurringProduct")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsRecurring)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsRecurring)
                            @Html.ValidationMessageFor(model => model.IsRecurring)
                        </div>
                    </div>
                    <div class="form-group" id="pnlCycleLength">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RecurringCycleLength)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.RecurringCycleLength)
                            @Html.ValidationMessageFor(model => model.RecurringCycleLength)
                        </div>
                    </div>
                    <div class="form-group" id="pnlCyclePeriod">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RecurringCyclePeriodId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.RecurringCyclePeriodId, ((RecurringProductCyclePeriod)Model.RecurringCyclePeriodId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.RecurringCyclePeriodId)
                        </div>
                    </div>
                    <div class="form-group" id="pnlTotalCycles">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RecurringTotalCycles)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.RecurringTotalCycles)
                            @Html.ValidationMessageFor(model => model.RecurringTotalCycles)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.IsRental ? null : "advanced-setting")" id="group-rental">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Rental")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsRental)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsRental)
                            @Html.ValidationMessageFor(model => model.IsRental)
                        </div>
                    </div>
                    <div class="form-group" id="pnlRentalPriceLength">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RentalPriceLength)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.RentalPriceLength)
                            @Html.ValidationMessageFor(model => model.RentalPriceLength)
                        </div>
                    </div>
                    <div class="form-group" id="pnlRentalPricePeriod">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.RentalPricePeriodId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.RentalPricePeriodId, ((RentalPricePeriod)Model.RentalPricePeriodId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.RentalPricePeriodId)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default" id="group-prices">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Prices")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Price)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Price) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.Price)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.OldPrice ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OldPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.OldPrice) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.OldPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.ProductCost ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.ProductCost)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.ProductCost) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.ProductCost)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.SpecialPrice ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SpecialPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.SpecialPrice) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.SpecialPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.SpecialPriceStartDate ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SpecialPriceStartDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.SpecialPriceStartDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.SpecialPriceStartDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.SpecialPriceEndDate ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SpecialPriceEndDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.SpecialPriceEndDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.SpecialPriceEndDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DisableBuyButton ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DisableBuyButton)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.DisableBuyButton)
                            @Html.ValidationMessageFor(model => model.DisableBuyButton)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DisableWishlistButton ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DisableWishlistButton)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.DisableWishlistButton)
                            @Html.ValidationMessageFor(model => model.DisableWishlistButton)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AvailableForPreOrder ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.AvailableForPreOrder)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.AvailableForPreOrder)
                            @Html.ValidationMessageFor(model => model.AvailableForPreOrder)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AvailableForPreOrder ? null : "advanced-setting")" id="pnlPreOrderAvailabilityStartDateTimeUtc">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.PreOrderAvailabilityStartDateTimeUtc)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.PreOrderAvailabilityStartDateTimeUtc)
                            @Html.ValidationMessageFor(model => model.PreOrderAvailabilityStartDateTimeUtc)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.CallForPrice ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CallForPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.CallForPrice)
                            @Html.ValidationMessageFor(model => model.CallForPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.CustomerEntersPrice ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CustomerEntersPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.CustomerEntersPrice)
                            @Html.ValidationMessageFor(model => model.CustomerEntersPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.CustomerEntersPrice ? null : "advanced-setting")" id="pnlMinimumCustomerEnteredPrice">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MinimumCustomerEnteredPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MinimumCustomerEnteredPrice) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.MinimumCustomerEnteredPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.CustomerEntersPrice ? null : "advanced-setting")" id="pnlMaximumCustomerEnteredPrice">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.MaximumCustomerEnteredPrice)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.MaximumCustomerEnteredPrice) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.MaximumCustomerEnteredPrice)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.PAngV ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.BasepriceEnabled)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.BasepriceEnabled)
                            @Html.ValidationMessageFor(model => model.BasepriceEnabled)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.PAngV ? null : "advanced-setting")" id="pnlBasepriceAmount">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.BasepriceAmount)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.BasepriceAmount)
                            @Html.ValidationMessageFor(model => model.BasepriceAmount)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.PAngV ? null : "advanced-setting")" id="pnlBasepriceUnit">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.BasepriceUnitId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.BasepriceUnitId, Model.AvailableBasepriceUnits)
                            @Html.ValidationMessageFor(model => model.BasepriceUnitId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.PAngV ? null : "advanced-setting")" id="pnlBasepriceBaseAmount">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.BasepriceBaseAmount)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.BasepriceBaseAmount)
                            @Html.ValidationMessageFor(model => model.BasepriceBaseAmount)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.PAngV ? null : "advanced-setting")" id="pnlBasepriceBaseUnit">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.BasepriceBaseUnitId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.BasepriceBaseUnitId, Model.AvailableBasepriceBaseUnits)
                            @Html.ValidationMessageFor(model => model.BasepriceBaseUnitId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Discounts ? null : "advanced-setting")">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SelectedDiscountIds)
                        </div>
                        <div class="col-md-9">
                            @Html.EditorFor(model => model.SelectedDiscountIds, new { SelectList = Model.AvailableDiscounts })
                            <script>
                                $(document).ready(function() {
                                    var discountsIdsInput = $('#@Html.FieldIdFor(model => model.SelectedDiscountIds)').data("kendoMultiSelect");
                                    discountsIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableDiscounts.Count == 0)
                            {
                                <text>
                                    discountsIdsInput.setOptions({
                                        enable: false,
                                        placeholder: '@T("Admin.Catalog.Products.Fields.Discounts.NoDiscounts")'
                                    });
                                    discountsIdsInput._placeholder();
                                    discountsIdsInput._enable();
                                    </text>
                            }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsTaxExempt)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsTaxExempt)
                            @Html.ValidationMessageFor(model => model.IsTaxExempt)
                        </div>
                    </div>
                    <div class="form-group" id="pnlTaxCategory">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.TaxCategoryId)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFDropDownListFor(model => model.TaxCategoryId, Model.AvailableTaxCategories)
                            @Html.ValidationMessageFor(model => model.TaxCategoryId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.TelecommunicationsBroadcastingElectronicServices ? null : "advanced-setting")" id="pnlIsTelecommunicationsOrBroadcastingOrElectronicServices">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.IsTelecommunicationsOrBroadcastingOrElectronicServices)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.IsTelecommunicationsOrBroadcastingOrElectronicServices)
                            @Html.ValidationMessageFor(model => model.IsTelecommunicationsOrBroadcastingOrElectronicServices)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.TierPrices ? null : "advanced-setting")" id="tier-prices">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.TierPrices")
                </div>
                <div class="panel-body">
                    <p>
                        @T("Admin.Catalog.Products.TierPrices.Hint")
                    </p>
                    @if (Model.Id > 0)
                    {
                        <div id="tierprices-grid"></div>

                        <script>
                            $(document).ready(function() {
                                $("#tierprices-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("TierPriceList", "Product", new {productId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            create: {
                                                url: "@Html.Raw(Url.Action("TierPriceInsert", "Product", new {productId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            update: {
                                                url: "@Html.Raw(Url.Action("TierPriceUpdate", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            destroy: {
                                                url: "@Html.Raw(Url.Action("TierPriceDelete", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            }
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                            model: {
                                                id: "Id",
                                                fields: {
                                                    Project: { editable: true, type: "string" },
                                                    ProjectId: { editable: true, type: "number" },
                                                    CustomerRole: { editable: true, type: "string" },
                                                    CustomerRoleId: { editable: true, type: "number" },
                                                    //ProductId: { editable: false, type: "number" },
                                                    Quantity: { editable: true, type: "number" },
                                                    Price: { editable: true, type: "number" },
                                                    Id: { editable: false, type: "number" }
                                                }
                                            }
                                        },
                                        requestEnd: function(e) {
                                            if (e.type == "create" || e.type == "update") {
                                                this.read();
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        numeric: false,
                                        previousNext: false,
                                        info: false
                                    },
                                    toolbar: [{ name: "create", text: "@T("Admin.Common.AddNewRecord")" }],
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [
                                        {
                                            field: "ProjectId",
                                            title: "@T("Admin.Catalog.Products.TierPrices.Fields.Project")",
                                            width: 250,
                                            editor: projectDropDownEditor,
                                            template: "#:Project#"
                                        },
                                        {
                                            field: "CustomerRoleId",
                                            title: "@T("Admin.Catalog.Products.TierPrices.Fields.CustomerRole")",
                                            width: 250,
                                            editor: customerRoleDropDownEditor,
                                            template: "#:CustomerRole#"
                                        },
                                        {
                                            field: "Quantity",
                                            title: "@T("Admin.Catalog.Products.TierPrices.Fields.Quantity")",
                                            width: 150,
                                            //integer format
                                            format: "{0:0}"
                                        }, {
                                            field: "Price",
                                            title: "@T("Admin.Catalog.Products.TierPrices.Fields.Price")",
                                            width: 150,
                                            editor: function(container, options) {
                                                $('<input name="' + options.field + '"/>')
                                                    .appendTo(container)
                                                    .kendoNumericTextBox({
                                                        format: "{0:n4}",
                                                        decimals: 4
                                                    });
                                            }
                                        }, {
                                            command: [
                                                {
                                                    name: "edit",
                                                    text: {
                                                        edit: "@T("Admin.Common.Edit")",
                                                        update: "@T("Admin.Common.Update")",
                                                        cancel: "@T("Admin.Common.Cancel")"
                                                    }
                                                }, {
                                                    name: "destroy",
                                                    text: "@T("Admin.Common.Delete")"
                                                }
                                            ],
                                            width: 200
                                        }
                                    ]
                                });
                            });

                            //local datasource
                            var allProjects = [
                                {
                                    Id: 0,
                                    Name: "@T("Admin.Configuration.Settings.AllSettings.Fields.ProjectName.AllProjects")"
                                }
                                @{
                                var projectService = EngineContext.Current.Resolve<IProjectService>();
                                var allProjects = projectService.GetAllProjects();
                            }
                                @foreach (var project in allProjects)
                            {
                                <text>
                                            , {
                                                Id: @(project.Id),
                                                Name: "@(Html.Raw(HttpUtility.JavaScriptStringEncode(project.Name)))"
                                            }
                                            </text>
                            }
                            ];

                            var allCustomerRoles = [
                                {
                                    Id: 0,
                                    Name: "@T("Admin.Catalog.Products.TierPrices.Fields.CustomerRole.All")"
                                }
                                @{
                                var customerService = EngineContext.Current.Resolve<ICustomerService>();
                                var allCustomerRoles = customerService.GetAllCustomerRoles(true);
                            }
                                @foreach (var customerRole in allCustomerRoles)
                            {
                                <text>
                                                , {
                                                    Id: @(customerRole.Id),
                                                    Name: "@(Html.Raw(HttpUtility.JavaScriptStringEncode(customerRole.Name)))"
                                                }
                                    </text>
                            }
                            ];

                            function projectDropDownEditor(container, options) {
                                $('<input required data-text-field="Name" data-value-field="Id" data-bind="value:ProjectId"/>')
                                    .appendTo(container)
                                    .kendoDropDownList({
                                        autoBind: false,
                                        dataSource: allProjects
                                    });
                            }

                            function customerRoleDropDownEditor(container, options) {
                                $('<input required data-text-field="Name" data-value-field="Id" data-bind="value:CustomerRoleId"/>')
                                    .appendTo(container)
                                    .kendoDropDownList({
                                        autoBind: false,
                                        dataSource: allCustomerRoles
                                    });
                            }
                        </script>
    }
    else
    {
        @T("Admin.Catalog.Products.TierPrices.SaveBeforeEdit")
    }
                </div>
            </div>
        </div>
    </div>
    <div class="@(Model.ProductEditorSettingsModel.OneColumnProductPage ? "col-md-12" : "col-md-5")">
        <div class="panel-group">
            @{
                var leftColumnClass = Model.ProductEditorSettingsModel.OneColumnProductPage ? "col-md-3" : "col-md-4";
                var rightColumnClass = Model.ProductEditorSettingsModel.OneColumnProductPage ? "col-md-9" : "col-md-8";
            }

            <div class="panel panel-default margin-bottom" id="group-associated-products">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.AssociatedProducts")
                </div>
                @if (Model.Id > 0)
                {
                    <div class="panel-body">
                        <ul class="common-list">
                            <li>
                                @T("Admin.Catalog.Products.AssociatedProducts.Note1")
                            </li>
                            <li>
                                @T("Admin.Catalog.Products.AssociatedProducts.Note2")
                            </li>
                        </ul>

                        <div id="associatedproducts-grid"></div>

                        <script>
                            $(document).ready(function() {
                                $("#associatedproducts-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("AssociatedProductList", "Product", new {productId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            update: {
                                                url: "@Html.Raw(Url.Action("AssociatedProductUpdate", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            destroy: {
                                                url: "@Html.Raw(Url.Action("AssociatedProductDelete", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            }
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                            model: {
                                                id: "Id",
                                                fields: {
                                                    ProductName: { editable: false, type: "string" },
                                                    DisplayOrder: { editable: true, type: "number" },
                                                    Id: { editable: false, type: "number" }
                                                }
                                            }
                                        },
                                        requestEnd: function(e) {
                                            if (e.type == "update") {
                                                this.read();
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        numeric: false,
                                        previousNext: false,
                                        info: false
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [
                                        {
                                            field: "ProductName",
                                            title: "@T("Admin.Catalog.Products.AssociatedProducts.Fields.Product")",
                                            template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=Id#">#=ProductName#</a>',
                                            width: 250
                                        }, {
                                            field: "DisplayOrder",
                                            title: "@T("Admin.Catalog.Products.AssociatedProducts.Fields.DisplayOrder")",
                                            //integer format
                                            format: "{0:0}",
                                            width: 120
                                        }, {
                                            command: [
                                                {
                                                    name: "edit",
                                                    text: {
                                                        edit: "@T("Admin.Common.Edit")",
                                                        update: "@T("Admin.Common.Update")",
                                                        cancel: "@T("Admin.Common.Cancel")"
                                                    }
                                                }, {
                                                    name: "destroy",
                                                    text: "@T("Admin.Common.Delete")"
                                                }
                                            ],
                                            width: 220
                                        }
                                    ]
                                });
                            });
                        </script>
                    </div>
                    <div class="panel-footer">
                        <button type="submit" id="btnAddNewAssociatedProduct" onclick="javascript:OpenWindow('@(Url.Action("AssociatedProductAddPopup", "Product", new {productId = Model.Id, btnId = "btnRefreshAssociatedProducts", formId = "product-form"}))', 800, 800, true); return false;" class="btn btn-primary">
                            @T("Admin.Catalog.Products.AssociatedProducts.AddNew")
                        </button>
                        <input type="submit" id="btnRefreshAssociatedProducts" style="display: none" />
                        <script type="text/javascript">
                            $(document).ready(function() {
                                $('#btnRefreshAssociatedProducts').click(function() {
                                    //refresh grid
                                    var grid = $("#associatedproducts-grid").data('kendoGrid');
                                    grid.dataSource.read();

                                    //return false to don't reload a page
                                    return false;
                                });
                            });
                        </script>
                    </div>
                }
                else
                {
                    <div class="panel-body">
                        @T("Admin.Catalog.Products.AssociatedProducts.SaveBeforeEdit")
                    </div>
                }
            </div>
            <div class="panel panel-default no-margin" id="group-inventory">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Inventory")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.ManageInventoryMethodId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.ManageInventoryMethodId, ((ManageInventoryMethod)Model.ManageInventoryMethodId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.ManageInventoryMethodId)
                        </div>
                    </div>
                    <div class="form-group" id="pnlStockQuantity">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.StockQuantity)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.StockQuantity)
                            @Html.HiddenFor(model => model.LastStockQuantity)
                            @Html.ValidationMessageFor(model => model.StockQuantity)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Warehouse ? null : "advanced-setting")" id="pnlWarehouse">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.WarehouseId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.WarehouseId, Model.AvailableWarehouses)
                            @Html.ValidationMessageFor(model => model.WarehouseId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.UseMultipleWarehouses ? null : "advanced-setting")" id="pnlUseMultipleWarehouses">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.UseMultipleWarehouses)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.UseMultipleWarehouses)
                            @Html.ValidationMessageFor(model => model.UseMultipleWarehouses)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.UseMultipleWarehouses ? null : "advanced-setting")" id="pnlMultipleWarehouses">
                        <div class="col-md-12" style="overflow-x: auto;">
                            @if (Model.ProductWarehouseInventoryModels.Count > 0)
            {
                                <table class="table table-hover table-bordered text-center">
                                    <thead>
                                        <tr>
                                            <th>
                                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.Warehouse")
                                            </th>
                                            <th>
                                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.WarehouseUsed")
                                            </th>
                                            <th>
                                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.StockQuantity")
                                            </th>
                                            <th>
                                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.ReservedQuantity")
                                            </th>
                                            <th>
                                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.PlannedQuantity")
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var item in Model.ProductWarehouseInventoryModels)
                                        {
                                            <tr>
                                                <td style="width: 36%;">
                                                    <div style="padding-left: 10px; padding-right: 10px;">
                                                        @item.WarehouseName
                                                    </div>
                                                </td>
                                                <td style="width: 10%;">
                                                    <input type="checkbox" id="warehouse_used_@(item.WarehouseId)" name="warehouse_used_@(item.WarehouseId)" value="@item.WarehouseId" checked="@item.WarehouseUsed" />
                                                    <script type="text/javascript">
                                                        $(document).ready(function() {
                                                            $("#warehouse_used_@(item.WarehouseId)").change(toggleWarehouseUsed_@(item.WarehouseId));
                                                            toggleWarehouseUsed_@(item.WarehouseId)();
                                                        });

                                                        function toggleWarehouseUsed_@(item.WarehouseId)() {
                                                            if ($('#warehouse_used_@(item.WarehouseId)').is(':checked')) {
                                                                $('#warehouse_qty_@(item.WarehouseId)').prop('disabled', false);
                                                                $('#warehouse_reserved_@(item.WarehouseId)').prop('disabled', false);
                                                            } else {
                                                                $('#warehouse_qty_@(item.WarehouseId)').prop('disabled', true);
                                                                $('#warehouse_reserved_@(item.WarehouseId)').prop('disabled', true);
                                                            }
                                                        }
                                                    </script>
                                                <td style="width: 18%;">
                                                    <input id="warehouse_qty_@(item.WarehouseId)" name="warehouse_qty_@(item.WarehouseId)" type="text" value="@item.StockQuantity" class="form-control" />
                                                </td>
                                                <td style="width: 18%;">
                                                    <input id="warehouse_reserved_@(item.WarehouseId)" name="warehouse_reserved_@(item.WarehouseId)" type="text" value="@item.ReservedQuantity" class="form-control" />
                                                </td>
                                                <td style="width: 18%;">
                                                    @item.PlannedQuantity
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                                <p>
                                    <em>@T("Admin.Catalog.Products.ProductWarehouseInventory.Description1")</em>
                                </p>
                                <p>
                                    <em>@T("Admin.Catalog.Products.ProductWarehouseInventory.Description2")</em>
                                </p>
                                <p>
                                    <em>@T("Admin.Catalog.Products.ProductWarehouseInventory.Description3")</em>
                                </p>
                            }
                            else
                            {
                                @T("Admin.Catalog.Products.ProductWarehouseInventory.Fields.Warehouse.NotDefined")
                            }
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DisplayStockAvailability ? null : "advanced-setting")" id="pnlDisplayStockAvailability">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.DisplayStockAvailability)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.DisplayStockAvailability)
                            @Html.ValidationMessageFor(model => model.DisplayStockAvailability)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DisplayStockQuantity ? null : "advanced-setting")" id="pnlDisplayStockQuantity">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.DisplayStockQuantity)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.DisplayStockQuantity)
                            @Html.ValidationMessageFor(model => model.DisplayStockQuantity)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MinimumStockQuantity ? null : "advanced-setting")" id="pnlMinStockQuantity">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.MinStockQuantity)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.MinStockQuantity)
                            @Html.ValidationMessageFor(model => model.MinStockQuantity)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.LowStockActivity ? null : "advanced-setting")" id="pnlLowStockActivity">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.LowStockActivityId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.LowStockActivityId, ((LowStockActivity)Model.LowStockActivityId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.LowStockActivityId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.NotifyAdminForQuantityBelow ? null : "advanced-setting")" id="pnlNotifyForQuantityBelow">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.NotifyAdminForQuantityBelow)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.NotifyAdminForQuantityBelow)
                            @Html.ValidationMessageFor(model => model.NotifyAdminForQuantityBelow)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Backorders ? null : "advanced-setting")" id="pnlBackorders">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.BackorderModeId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.BackorderModeId, ((BackorderMode)Model.BackorderModeId).ToSelectList())
                            @Html.ValidationMessageFor(model => model.BackorderModeId)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AllowBackInStockSubscriptions ? null : "advanced-setting")" id="pnlAllowBackInStockSubscriptions">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.AllowBackInStockSubscriptions)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.AllowBackInStockSubscriptions)
                            @Html.ValidationMessageFor(model => model.AllowBackInStockSubscriptions)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MinimumCartQuantity ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.OrderMinimumQuantity)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.OrderMinimumQuantity)
                            @Html.ValidationMessageFor(model => model.OrderMinimumQuantity)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.MaximumCartQuantity ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.OrderMaximumQuantity)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.OrderMaximumQuantity)
                            @Html.ValidationMessageFor(model => model.OrderMaximumQuantity)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AllowedQuantities ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.AllowedQuantities)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.AllowedQuantities)
                            @Html.ValidationMessageFor(model => model.AllowedQuantities)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AllowAddingOnlyExistingAttributeCombinations ? null : "advanced-setting")" id="pnlAllowAddingOnlyExistingAttributeCombinations">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.AllowAddingOnlyExistingAttributeCombinations)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.AllowAddingOnlyExistingAttributeCombinations)
                            @Html.ValidationMessageFor(model => model.AllowAddingOnlyExistingAttributeCombinations)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.NotReturnable ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.NotReturnable)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.NotReturnable)
                            @Html.ValidationMessageFor(model => model.NotReturnable)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default" id="group-shipping">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Shipping")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.IsShipEnabled)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.IsShipEnabled)
                            @Html.ValidationMessageFor(model => model.IsShipEnabled)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Weight ? null : "advanced-setting")" id="pnlWeight">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.Weight)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.Weight) [@Model.BaseWeightIn]
                            @Html.ValidationMessageFor(model => model.Weight)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Dimensions ? null : "advanced-setting")" id="pnlLength">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.Length)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.Length) [@Model.BaseDimensionIn]
                            @Html.ValidationMessageFor(model => model.Length)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Dimensions ? null : "advanced-setting")" id="pnlWidth">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.Width)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.Width) [@Model.BaseDimensionIn]
                            @Html.ValidationMessageFor(model => model.Width)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Dimensions ? null : "advanced-setting")" id="pnlHeight">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.Height)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.Height) [@Model.BaseDimensionIn]
                            @Html.ValidationMessageFor(model => model.Height)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.FreeShipping ? null : "advanced-setting")" id="pnlFreeShipping">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.IsFreeShipping)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.IsFreeShipping)
                            @Html.ValidationMessageFor(model => model.IsFreeShipping)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.ShipSeparately ? null : "advanced-setting")" id="pnlShipSeparately">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.ShipSeparately)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.ShipSeparately)
                            @Html.ValidationMessageFor(model => model.ShipSeparately)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.AdditionalShippingCharge ? null : "advanced-setting")" id="pnlAdditionalShippingCharge">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.AdditionalShippingCharge)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.AdditionalShippingCharge) [@Model.PrimaryProjectCurrencyCode]
                            @Html.ValidationMessageFor(model => model.AdditionalShippingCharge)
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.DeliveryDate ? null : "advanced-setting")" id="pnlDeliveryDate">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.DeliveryDateId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.DeliveryDateId, Model.AvailableDeliveryDates)
                            @Html.ValidationMessageFor(model => model.DeliveryDateId)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Mappings")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.SelectedCategoryIds)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.EditorFor(model => model.SelectedCategoryIds, new { SelectList = Model.AvailableCategories })
                            <script>
                                $(document).ready(function() {
                                    var categoryIdsInput = $('#@Html.FieldIdFor(model => model.SelectedCategoryIds)').data("kendoMultiSelect");
                                    categoryIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableCategories.Count == 0)
                            {
                                <text>
                                    categoryIdsInput.setOptions({
                                        enable: false,
                                        placeholder: '@T("Admin.Catalog.Products.Fields.Categories.NoCategoriesAvailable")'
                                    });
                                    categoryIdsInput._placeholder();
                                    categoryIdsInput._enable();
                                    </text>
                            }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Manufacturers ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.SelectedManufacturerIds)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.EditorFor(model => model.SelectedManufacturerIds, new { SelectList = Model.AvailableManufacturers })
                            <script>
                                $(document).ready(function() {
                                    var manufacturersIdsInput = $('#@Html.FieldIdFor(model => model.SelectedManufacturerIds)').data("kendoMultiSelect");
                                    manufacturersIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableManufacturers.Count == 0)
                            {
                                <text>
                                    manufacturersIdsInput.setOptions({
                                        enable: false,
                                        placeholder: '@T("Admin.Catalog.Products.Fields.Manufacturers.NoManufacturersAvailable")'
                                    });
                                    manufacturersIdsInput._placeholder();
                                    manufacturersIdsInput._enable();
                                    </text>
                            }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Projects ? null : "advanced-setting")">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.SelectedProjectIds)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.EditorFor(model => model.SelectedProjectIds, new { SelectList = Model.AvailableProjects })
                            <script>
                                $(document).ready(function() {
                                    var projectsIdsInput = $('#@Html.FieldIdFor(model => model.SelectedProjectIds)').data("kendoMultiSelect");
                                    projectsIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableProjects.Count == 0)
                            {
                                <text>
                                    projectsIdsInput.setOptions({
                                        enable: false,
                                        placeholder: 'No Projects available'
                                    });
                                    projectsIdsInput._placeholder();
                                    projectsIdsInput._enable();
                                    </text>
                            }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group @(Model.ProductEditorSettingsModel.Vendor ? null : "advanced-setting")" @(Model.IsLoggedInAsVendor ? Html.Raw("style='display: none;'") : null)>
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.VendorId)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFDropDownListFor(model => model.VendorId, Model.AvailableVendors)
                            @Html.ValidationMessageFor(model => model.VendorId)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.ACL ? null : "advanced-setting")">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.Security")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.SelectedCustomerRoleIds)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.EditorFor(model => model.SelectedCustomerRoleIds, new { SelectList = Model.AvailableCustomerRoles })
                            <script>
                                $(document).ready(function() {
                                    var rolesIdsInput = $('#@Html.FieldIdFor(model => model.SelectedCustomerRoleIds)').data("kendoMultiSelect");
                                    rolesIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableCustomerRoles.Count == 0)
                            {
                                <text>
                                    rolesIdsInput.setOptions({
                                        enable: false,
                                        placeholder: 'No customer roles available'
                                    });
                                    rolesIdsInput._placeholder();
                                    rolesIdsInput._enable();
                                    </text>
                            }
                                });
                            </script>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.RequireOtherProductsAddedToTheCart ? null : "advanced-setting")" id="group-required-other-products">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.RequireOtherProducts")
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.RequireOtherProducts)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.RequireOtherProducts)
                            @Html.ValidationMessageFor(model => model.RequireOtherProducts)
                        </div>
                    </div>
                    <div id="pnlRequiredProductIds">
                        <div class="form-group">
                            <div class="@leftColumnClass">
                                @Html.SDFLabelFor(model => model.RequiredProductIds)
                            </div>
                            <div class="@rightColumnClass">
                                <div class="input-group">
                                    @Html.SDFEditorFor(model => model.RequiredProductIds)
                                    <span class="input-group-btn">
                                        <input type="submit" id="btnRefreshRequiredProducts" style="display: none" />
                                        <script type="text/javascript">
                                            $(document).ready(function() {
                                                $('#btnRefreshRequiredProducts').click(function() {
                                                    //refresh product list
                                                    loadRequiredProductFriendlyNames();

                                                    //return false to don't reload a page
                                                    return false;
                                                });
                                            });
                                        </script>
                                        <button type="submit" id="btnAddNewRequiredProduct" onclick="javascript:OpenWindow('@(Url.Action("RequiredProductAddPopup", "Product", new {btnId = "btnRefreshRequiredProducts", productIdsInput = "RequiredProductIds"}))', 800, 850, true); return false;" class="btn btn-info">
                                            @T("Admin.Catalog.Products.Fields.RequiredProductIds.AddNew")
                                        </button>
                                    </span>
                                </div>
                                @Html.ValidationMessageFor(model => model.RequiredProductIds)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="@leftColumnClass">
                                <span id="required-products-check-progress" style="display: none; float: right" class="please-wait">@T("Common.Wait...")</span>
                            </div>
                            <div class="@rightColumnClass">
                                <span id="required-product-names"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" id="pnlAutomaticallyAddRequiredProducts">
                        <div class="@leftColumnClass">
                            @Html.SDFLabelFor(model => model.AutomaticallyAddRequiredProducts)
                        </div>
                        <div class="@rightColumnClass">
                            @Html.SDFEditorFor(model => model.AutomaticallyAddRequiredProducts)
                            @Html.ValidationMessageFor(model => model.AutomaticallyAddRequiredProducts)
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.RelatedProducts ? null : "advanced-setting")">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.RelatedProducts")
                </div>
                @if (Model.Id > 0)
                {
                    <div class="panel-body">
                        <p>
                            @T("Admin.Catalog.Products.RelatedProducts.Hint")
                        </p>
                        <div id="relatedproducts-grid"></div>

                        <script>
                            $(document).ready(function() {
                                $("#relatedproducts-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("RelatedProductList", "Product", new {productId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            update: {
                                                url: "@Html.Raw(Url.Action("RelatedProductUpdate", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            destroy: {
                                                url: "@Html.Raw(Url.Action("RelatedProductDelete", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            }
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                            model: {
                                                id: "Id",
                                                fields: {
                                                    Product2Name: { editable: false, type: "string" },
                                                    DisplayOrder: { editable: true, type: "number" },
                                                    ProductId2: { editable: false, type: "number" }
                                                }
                                            }
                                        },
                                        requestEnd: function(e) {
                                            if (e.type == "update") {
                                                this.read();
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        numeric: false,
                                        previousNext: false,
                                        info: false
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [
                                        {
                                            field: "Product2Name",
                                            title: "@T("Admin.Catalog.Products.RelatedProducts.Fields.Product")",
                                            width: 250,
                                            template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId2#">#=Product2Name#</a>'
                                        }, {
                                            field: "DisplayOrder",
                                            title: "@T("Admin.Catalog.Products.RelatedProducts.Fields.DisplayOrder")",
                                            //integer format
                                            format: "{0:0}",
                                            width: 120
                                        }, {
                                            command: [
                                                {
                                                    name: "edit",
                                                    text: {
                                                        edit: "@T("Admin.Common.Edit")",
                                                        update: "@T("Admin.Common.Update")",
                                                        cancel: "@T("Admin.Common.Cancel")"
                                                    }
                                                }, {
                                                    name: "destroy",
                                                    text: "@T("Admin.Common.Delete")"
                                                }
                                            ],
                                            width: 220
                                        }
                                    ]
                                });
                            });
                        </script>
                    </div>
                    <div class="panel-footer">
                        <button type="submit" id="btnAddNewRelatedProduct" class="btn btn-primary" onclick="javascript:OpenWindow('@(Url.Action("RelatedProductAddPopup", "Product", new {productId = Model.Id, btnId = "btnRefreshRelatedProducts", formId = "product-form"}))', 800, 800, true); return false;">
                            @T("Admin.Catalog.Products.RelatedProducts.AddNew")
                        </button>
                        <input type="submit" id="btnRefreshRelatedProducts" style="display: none" />
                        <script type="text/javascript">
                            $(document).ready(function() {
                                $('#btnRefreshRelatedProducts').click(function() {
                                    //refresh grid
                                    var grid = $("#relatedproducts-grid").data('kendoGrid');
                                    grid.dataSource.read();

                                    //return false to don't reload a page
                                    return false;
                                });
                            });
                        </script>
                    </div>
                }
                else
                {
                    <div class="panel-body">
                        @T("Admin.Catalog.Products.RelatedProducts.SaveBeforeEdit")
                    </div>
                }
            </div>
            <div class="panel panel-default @(Model.ProductEditorSettingsModel.CrossSellsProducts ? null : "advanced-setting")">
                <div class="panel-heading">
                    @T("Admin.Catalog.Products.CrossSells")
                </div>
                @if (Model.Id > 0)
                {
                    <div class="panel-body">
                        <p>
                            @T("Admin.Catalog.Products.CrossSells.Hint")
                        </p>
                        <div id="crosssellproducts-grid"></div>

                        <script>
                            $(document).ready(function() {
                                $("#crosssellproducts-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("CrossSellProductList", "Product", new {productId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                            destroy: {
                                                url: "@Html.Raw(Url.Action("CrossSellProductDelete", "Product"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            }
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                            model: {
                                                id: "Id",
                                                fields: {
                                                    Product2Name: { editable: false, type: "string" },
                                                    ProductId2: { editable: false, type: "number" }
                                                }
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        numeric: false,
                                        previousNext: false,
                                        info: false
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [
                                        {
                                            field: "Product2Name",
                                            title: "@T("Admin.Catalog.Products.CrossSells.Fields.Product")",
                                            template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId2#">#=Product2Name#"</a>'
                                        }, {
                                            command: { name: "destroy", text: "@T("Admin.Common.Delete")" },
                                            title: "@T("Admin.Common.Delete")",
                                            width: 200
                                        }
                                    ]
                                });
                            });
                        </script>
                    </div>
                    <div class="panel-footer">
                        <button type="submit" id="btnAddNewCrossSellProduct" onclick="javascript:OpenWindow('@(Url.Action("CrossSellProductAddPopup", "Product", new {productId = Model.Id, btnId = "btnRefreshCrossSellProducts", formId = "product-form"}))', 800, 800, true); return false;" class="btn btn-primary">
                            @T("Admin.Catalog.Products.CrossSells.AddNew")
                        </button>
                        <input type="submit" id="btnRefreshCrossSellProducts" style="display: none" />
                        <script type="text/javascript">
                            $(document).ready(function() {
                                $('#btnRefreshCrossSellProducts').click(function() {
                                    //refresh grid
                                    var grid = $("#crosssellproducts-grid").data('kendoGrid');
                                    grid.dataSource.read();

                                    //return false to don't reload a page
                                    return false;
                                });
                            });
                        </script>
                    </div>
                }
                else
                {
                    <div class="panel-body">
                        @T("Admin.Catalog.Products.CrossSells.SaveBeforeEdit")
                    </div>
                }
            </div>
        </div>
    </div>
</div>